<?php
/*##################################################

# 模块功能：lywq自定义弹窗配置
###################################################*/
error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
if(!@$_SERVER['HTTP_REFERER']) header('location:/');

$info = 'info.ini';
$version = parse_ini_file($info);

if (!file_exists($info)) {
	exit('未检测到info.ini配置文件,请检查 addons/pupop/info.ini 文件是否存在！');
}
$config = './config/config.php';
if (!file_exists($config)) {
  $configfile = fopen("./config/config.php", "w") or die("Unable to open file!");
  fwrite($configfile, "<?php $"."lywq "."=array ();");
  fclose($configfile);
}
require($config);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>lywq自定义弹窗设置</title>
    <link href="/static/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <script src="/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="/static/js/jquery.js"></script>
	<style>.layui-input-inline textarea{min-width:300px;min-height:150px;}
	.layui-form-item .layui-form-label{min-width:130px;}
	</style>
</head>
<body style="margin:20px 20px">
<style>.showpic {position:absolute; max-width:400px; max-height:500px; text-align:center; line-height:150%; border:2px solid #DEEFFA; padding:5px; background:#FFFFFF;  z-index:99999;}</style>
<div class="showpic" style="display:none;"><img class="showpic_img" width="100%" height="100%"></div>
<form class="layui-form layui-form-pane" action="">
<div class="layui-tab">
  <ul class="layui-tab-title">
    <li class="layui-this">lywq自定义弹窗</li>
    <li>赞助支持</li>
    <li>自动弹窗设置</li>
    <li>手动弹窗设置</li>
    <li>炫酷设置</li>
  </ul>
  <div class="layui-tab-content">
    <!-- 介绍页 -->
    <div class="layui-tab-item layui-show">
      <blockquote class="layui-elem-quote layui-quote-nm">
        <p>欢迎使用lywq自定义弹窗插件</p>
        <p><span style="color:red;">注意：</span>本插件为模板辅助插件，请在模板中（<span style="color:red;">public / foot.html文件</span>）插入如下代码：<span style="font-weight:bold;color:green;">{php}require('./addons/pupop/html/lywq_pupop.html');{/php}</span></p>
      </blockquote>
      <table class="layui-table">
        <colgroup>
          <col width="100">
            <col width="150">
              <col></colgroup>
        <thead>
          <tr>
            <th colspan="2" scope="col">弹窗简介</th>
            <th colspan="1" scope="col">使用说明</th></tr>
        </thead>
        <tbody>
          <tr>
            <td>名称</td>
            <td>
              <a href="https://www.muyin.life" target="_blank"><?php echo $version['title'] ;?> <?php echo $version['version'] ;?></a></td>
            <td>1. PHP版本≥5.6</td></tr>
          <tr>
            <td>作者</td>
            <td>
              <a href="<?php echo $version['website'] ;?>" target="_blank"><?php echo $version['author'] ;?></a></td>
            <td>2. 插件均为作者原创开发，不定时更新。</td></tr>
          <tr>
            <td>官方Q群</td>
            <td>
              <a href="https://jq.qq.com/?_wv=1027&k=szDVe4dO" target="_blank">294075802</a></td>
            <td>3. 意见、反馈、功能建议，请加入官方QQ群一起沟通交流！</td></tr>
          <tr>
            <td>作者QQ</td>
            <td>
              <a href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $version['qq'] ;?>&site=qq&menu=yes" target="_blank"><?php echo $version['qq'] ;?></a></td>
            <td>4. 唯一官方QQ，购买非官方制作源码，无任何技术支持及售后服务！</td></tr>
          <tr>
            <td>更新时间</td>
            <td><?php echo $version['updatetime'] ;?></td>
            <td>5. 肆意散播转售或者倒卖，将视为放弃一切技术支持。</td></tr>
          <tr>
            <td style="color:red;">使用教程</td>
            <td>
              <a href="<?php echo $version['tutorial'] ;?>" style="color:blue;" target="_blank">查看教程</a></td>
            <td>6. 使用盗版源码遇到任何问题本人概不负责！</td></tr>
          <tr>
            <td style="color:red;">更新日志</td>
            <td colspan="2" style="color:#2E8B57;">
              <?php echo $version['updatelog'] ;?></td></tr>
          <tr>
            <td colspan="3">请务必尊重知识产权，严格保证不恶意传播产品源码、不得直接对源码进行二次转售或倒卖等。一经发现，我们有权利终止你在我方购买的所有源码的售后技术支持。</td></tr>
        </tbody>
      </table>
    </div>

    <!-- 赞助支持 -->
    <div class="layui-tab-item">
      <blockquote class="layui-elem-quote layui-quote-nm">
        <p>您好，首先非常感谢您使用lywq自定义弹窗插件！</p>
        <p>本插件为<span style="color:red;">完全免费</span>插件，目前作者唯一收入为捐赠，免费程序的开发离不开金钱，还请各位多多支持！</p>
        <p></p>
        <p></p>
      </blockquote>
      <!--赞赏二维码-->
      <table class="layui-table">
        <thead>
          <tr>
            <th colspan="3">赞赏部分</th>
        </tr>
        </thead>
        <tbody>
            <tr align="center">
                <td width="20%">微信二维码</td>
                <td width="20%">支付宝二维码</td>
                <td width="60%">话说</td>
            </tr>
            <tr align="center">
                <td width="20%"><a href="https://s3.ax1x.com/2021/02/01/yVBih8.png" target="_blank"><img src="https://s3.ax1x.com/2021/02/01/yVBih8.png" width="auto" /></a></td>
                <td width="20%"><a href="https://s3.ax1x.com/2021/02/01/yVBk9S.jpg" target="_blank"><img src="https://s3.ax1x.com/2021/02/01/yVBk9S.jpg" width="280px" /></a></td>
                <td width="60%">
                <p style="color:#FF0000;">自愿赞赏，不强求，金额随意，一分也是爱！</p>
                <p style="color:#FF8C00;">您的支持将是我最大的动力，加油，奥力给！</p>
                <p><a style="color:	#1E90FF;" href="https://jq.qq.com/?_wv=1027&k=szDVe4dO" target="_blank">点击进群，一起交流插件！</a></p>
                </td>
            </tr>
        </tbody>
      </table>
      <!--广告赞助-->
      <table class="layui-table">
        <thead>
          <tr>
            <th colspan="3">广告部分</th>
        </tr>
        </thead>
        <tbody>
            <tr align="center">
                <td>
                   <iframe src="https://www.muyin.life/ads/lywq_pupop/lywq_pupop_ads.html" width="100%" height="320px" frameborder="0" scrolling="yes"></iframe>
                </td>
            </tr>
        </tbody>
      </table>
      <!--友情链接-->
      <table class="layui-table">
        <thead>
          <tr>
            <th colspan="3">友链部分</th>
        </tr>
        </thead>
        <tbody>
            <tr align="center">
                <td>
                   <iframe src="https://www.muyin.life/ads/lywq_pupop/lywq_pupop_link.html" width="100%" height="180px" frameborder="0" scrolling="yes"></iframe>
                </td>
            </tr>
        </tbody>
      </table>
    </div>

    <!-- 自动弹窗设置 -->
    <div class="layui-tab-item">
      <blockquote class="layui-elem-quote layui-quote-nm">
        <p><span style="color:red;">小提示：</span>下方的跳转链接可以设置跳转到app，例如：<span style="font-weight:bold;color:green;">微信：weixin:// &nbsp;&nbsp; QQ：mqqwpa:// &nbsp;&nbsp; 支付宝：alipays://</span></p>
      </blockquote>
      
        <div class="layui-form-item">
          <label class="layui-form-label">弹窗状态</label>
          <div class="layui-input-inline">
            <input type="checkbox" name="lywq_pupop_status" lay-skin="switch" lay-text="开启|关闭" value="1" <?php echo $lywq['pupop']['status']?'checked':'';?>>
          </div>
          <div class="layui-form-mid layui-word-aux">关闭后，弹窗均不显示</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">多端显示：</label>
            <div class="layui-input-inline" style="width:500px;">
                <input type="checkbox" lay-skin="primary" name="lywq_pupop_terminal[]" value="pc" title="电脑端" <?php echo strpos($lywq['pupop']['terminal'],'pc')!==false?'checked':'';?> >
                <input type="checkbox" lay-skin="primary" name="lywq_pupop_terminal[]" value="android" title="Android端" <?php echo strpos($lywq['pupop']['terminal'],'android')!==false?'checked':'';?> >
                <input type="checkbox" lay-skin="primary" name="lywq_pupop_terminal[]" value="ios" title="ios端" <?php echo strpos($lywq['pupop']['terminal'],'ios')!==false?'checked':'';?> >
                <input type="checkbox" lay-skin="primary" name="lywq_pupop_terminal[]" value="weixin" title="微信端" <?php echo strpos($lywq['pupop']['terminal'],'weixin')!==false?'checked':'';?> >
                <input type="checkbox" lay-skin="primary" name="lywq_pupop_terminal[]" value="qq" title="QQ端" <?php echo strpos($lywq['pupop']['terminal'],'qq')!==false?'checked':'';?> >
                <input type="checkbox" lay-skin="primary" name="lywq_pupop_terminal[]" value="bsl" title="变色龙" <?php echo strpos($lywq['pupop']['terminal'],'bsl')!==false?'checked':'';?> >
            </div>
            <div class="layui-form-mid layui-word-aux">勾选需要显示的终端</div>
        </div>

        <div class="layui-form-item">
           <label class="layui-form-label">弹窗间隔类型：</label>
           <div class="layui-input-inline" style="width:450px;">
             <input type="radio" name="lywq_pupop_interval_type" value="0" title="关闭" <?php echo $lywq['pupop']['interval']['type']==0?'checked':'';?>>
             <input type="radio" name="lywq_pupop_interval_type" value="1" title="间隔弹出" <?php echo $lywq['pupop']['interval']['type']==1?'checked':'';?>>
             <input type="radio" name="lywq_pupop_interval_type" value="2" title="次数弹出" <?php echo $lywq['pupop']['interval']['type']==2?'checked':'';?>>
           </div>
           <div class="layui-form-mid layui-word-aux">关闭后，默认刷新页面就弹出</div>
        </div>
        <div class="layui-form-item" <?php if ($lywq['pupop']['interval']['type'] != 1) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">间隔时间：</label>
           <div class="layui-input-inline">
              <input type="text" name="lywq_pupop_interval_time" placeholder="填写间隔时间" value="<?php echo $lywq['pupop']['interval']['time'];?>" autocomplete="off" class="layui-input">
           </div>
           <div class="layui-form-mid layui-word-aux">单位：分钟</div>
        </div>
        <div class="layui-form-item" <?php if ($lywq['pupop']['interval']['type'] != 2) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">弹出次数：</label>
           <div class="layui-input-inline">
              <input type="text" name="lywq_pupop_interval_number" placeholder="填写弹出次数" value="<?php echo $lywq['pupop']['interval']['number'];?>" autocomplete="off" class="layui-input">
           </div>
           <div class="layui-form-mid layui-word-aux">每天弹出次数</div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">弹窗标题</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_pupop_title" placeholder="请填写弹窗标题" value="<?php echo $lywq['pupop']['title'];?>" autocomplete="off" class="layui-input">
          </div>
        </div>

        <div class="layui-form-item">
           <label class="layui-form-label">弹窗内容类型：</label>
           <div class="layui-input-block">
             <input type="radio" name="lywq_pupop_type" value="1" title="图片" <?php echo $lywq['pupop']['type']==1?'checked':'';?>>
             <input type="radio" name="lywq_pupop_type" value="2" title="文字" <?php echo $lywq['pupop']['type']==2?'checked':'';?>>
             <input type="radio" name="lywq_pupop_type" value="3" title="图片加文字" <?php echo $lywq['pupop']['type']==3?'checked':'';?>>
           </div>
           <div class="layui-form-mid layui-word-aux">选择后请点击一下保存</div>
        </div>
        <div class="layui-form-item" <?php if (($lywq['pupop']['type'] != 1) && ($lywq['pupop']['type'] != 3)) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">图片地址：</label>
           <div class="layui-input-inline">
             <input type="text" name="lywq_pupop_content_image" placeholder="请填写弹窗图片地址" value="<?php echo $lywq['pupop']['content']['image'];?>" autocomplete="off" class="layui-input upload-input upload-img">
           </div>
           <div class="layui-input-inline" style="width:100px;">
             <span class="layui-btn layui-upload">上传图片</span>
           </div>
           <div class="layui-form-mid layui-word-aux">填写地址需带http</div>
        </div>
        <div class="layui-form-item" <?php if (($lywq['pupop']['type'] != 2) && ($lywq['pupop']['type'] != 3)) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">文字内容：</label>
           <div class="layui-input-inline w300">
               <textarea name="lywq_pupop_content_text" class="layui-input"  placeholder="请输入弹窗文字内容"><?php echo $lywq['pupop']['content']['text'];?></textarea>
           </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">左按钮名称</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_pupop_leftbutton_name" placeholder="请填写左按钮名称" value="<?php echo $lywq['pupop']['leftbutton']['name'];?>" autocomplete="off" class="layui-input">
          </div>
          <label class="layui-form-label">跳转链接</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_pupop_leftbutton_url" placeholder="点击跳转链接" value="<?php echo $lywq['pupop']['leftbutton']['url'];?>" autocomplete="off" class="layui-input">
          </div>
          <div class="layui-form-mid layui-word-aux">不跳转，留空</div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">右按钮名称</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_pupop_rightbutton_name" placeholder="请填写右按钮名称" value="<?php echo $lywq['pupop']['rightbutton']['name'];?>" autocomplete="off" class="layui-input">
          </div>
          <label class="layui-form-label">跳转链接</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_pupop_rightbutton_url" placeholder="点击跳转链接" value="<?php echo $lywq['pupop']['rightbutton']['url'];?>" autocomplete="off" class="layui-input">
          </div>
          <div class="layui-form-mid layui-word-aux">不跳转，留空</div>
        </div>

        <!-- 保存 -->
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="systemsave">保存配置</button></div>
        </div>
    </div>
    <!--手动弹窗设置-->
    <div class="layui-tab-item">
      <blockquote class="layui-elem-quote layui-quote-nm">
        <p>手动弹窗与自动弹窗互不干扰，搭配使用效果更佳！</p>
        <p><span style="color:red;">使用方法：</span>给需要弹窗的按钮添加 <span style="color:red;">onclick="lywq_openHpupop()"</span> 事件，例如：<span style="font-weight:bold;color:green;">&lt;a href="javascript:void(0)" onclick="lywq_openHpupop()"&gt;点击弹窗&lt;/a&gt;</span></p>
        <p><span style="color:red;">小提示：</span>下方的跳转链接可以设置跳转到app，例如：<span style="font-weight:bold;color:green;">微信：weixin:// &nbsp;&nbsp; QQ：mqqwpa:// &nbsp;&nbsp; 支付宝：alipays://</span></p>
      </blockquote>

        <div class="layui-form-item">
          <label class="layui-form-label">弹窗标题</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_Hpupop_title" placeholder="请填写弹窗标题" value="<?php echo $lywq['Hpupop']['title'];?>" autocomplete="off" class="layui-input">
          </div>
        </div>

        <div class="layui-form-item">
           <label class="layui-form-label">弹窗内容类型：</label>
           <div class="layui-input-block">
             <input type="radio" name="lywq_Hpupop_type" value="1" title="图片" <?php echo $lywq['Hpupop']['type']==1?'checked':'';?>>
             <input type="radio" name="lywq_Hpupop_type" value="2" title="文字" <?php echo $lywq['Hpupop']['type']==2?'checked':'';?>>
             <input type="radio" name="lywq_Hpupop_type" value="3" title="图片加文字" <?php echo $lywq['Hpupop']['type']==3?'checked':'';?>>
           </div>
           <div class="layui-form-mid layui-word-aux">选择后请点击一下保存</div>
        </div>
        <div class="layui-form-item" <?php if (($lywq['Hpupop']['type'] != 1) && ($lywq['Hpupop']['type'] != 3)) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">图片地址：</label>
           <div class="layui-input-inline">
             <input type="text" name="lywq_Hpupop_content_image" placeholder="请填写弹窗图片地址" value="<?php echo $lywq['Hpupop']['content']['image'];?>" autocomplete="off" class="layui-input upload-input upload-img">
           </div>
           <div class="layui-input-inline" style="width:100px;">
             <span class="layui-btn layui-upload">上传图片</span>
           </div>
           <div class="layui-form-mid layui-word-aux">填写地址需带http</div>
        </div>
        <div class="layui-form-item" <?php if (($lywq['Hpupop']['type'] != 2) && ($lywq['Hpupop']['type'] != 3)) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">文字内容：</label>
           <div class="layui-input-inline w300">
               <textarea name="lywq_Hpupop_content_text" class="layui-input"  placeholder="请输入弹窗文字内容"><?php echo $lywq['Hpupop']['content']['text'];?></textarea>
           </div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">左按钮名称</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_Hpupop_leftbutton_name" placeholder="请填写左按钮名称" value="<?php echo $lywq['Hpupop']['leftbutton']['name'];?>" autocomplete="off" class="layui-input">
          </div>
          <label class="layui-form-label">跳转链接</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_Hpupop_leftbutton_url" placeholder="点击跳转链接" value="<?php echo $lywq['Hpupop']['leftbutton']['url'];?>" autocomplete="off" class="layui-input">
          </div>
          <div class="layui-form-mid layui-word-aux">不跳转，留空</div>
        </div>

        <div class="layui-form-item">
          <label class="layui-form-label">右按钮名称</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_Hpupop_rightbutton_name" placeholder="请填写右按钮名称" value="<?php echo $lywq['Hpupop']['rightbutton']['name'];?>" autocomplete="off" class="layui-input">
          </div>
          <label class="layui-form-label">跳转链接</label>
          <div class="layui-input-inline">
            <input type="text" name="lywq_Hpupop_rightbutton_url" placeholder="点击跳转链接" value="<?php echo $lywq['Hpupop']['rightbutton']['url'];?>" autocomplete="off" class="layui-input">
          </div>
          <div class="layui-form-mid layui-word-aux">不跳转，留空</div>
        </div>

        <!-- 保存 -->
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="systemsave">保存配置</button></div>
        </div>
    </div>
    
    <!--炫酷设置-->
    <div class="layui-tab-item">
        <div class="layui-form-item">
          <label class="layui-form-label">下雪开关</label>
          <div class="layui-input-inline">
            <input type="checkbox" name="lywq_pupop_snow_status" lay-skin="switch" lay-text="开启|关闭" value="1" <?php echo $lywq['pupop']['snow']['status']?'checked':'';?>>
          </div>
        </div>
        <div class="layui-form-item">
           <label class="layui-form-label">下雪样式：</label>
           <div class="layui-input-inline" style="width:450px;">
             <input type="radio" name="lywq_pupop_snow_type" value="1" title="默认样式" <?php echo $lywq['pupop']['snow']['type']==1?'checked':'';?>>
             <input type="radio" name="lywq_pupop_snow_type" value="2" title="自定义样式（上传自定义透明png图片）" <?php echo $lywq['pupop']['snow']['type']==2?'checked':'';?>>
           </div>
        </div>
        <div class="layui-form-item" <?php if ($lywq['pupop']['snow']['type'] != 2) { echo 'style="display:none;"';} ?> >
           <label class="layui-form-label">图片地址：</label>
           <div class="layui-input-inline">
             <input type="text" name="lywq_pupop_snow_image" placeholder="请填写图片地址" value="<?php echo $lywq['pupop']['snow']['image'];?>" autocomplete="off" class="layui-input upload-input upload-img">
           </div>
           <div class="layui-input-inline" style="width:100px;">
             <span class="layui-btn layui-upload">上传图片</span>
           </div>
           <div class="layui-form-mid layui-word-aux">填写地址需带http</div>
        </div>


        <!-- 保存 -->
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="systemsave">保存配置</button></div>
        </div>
    </div>
  </div>
</div>
</form>


<script>
layui.use(['layer', 'form', 'table', 'upload', 'element'], function(){
  var layer = layui.layer 
  ,form = layui.form
  ,table = layui.table 
  ,upload = layui.upload
  ,element = layui.element 
  var upload_path = $('.j-ajax', parent.document).attr('href').replace('/index/clear.html', '') + '/upload/upload.html?flag=addon';
  var ishttps = 'https:' == document.location.protocol ? 'https://': 'http://';
        upload.render({
            elem: '.layui-upload'
            ,url: upload_path
            ,method: 'post'
            ,before: function(input) {
                layer.msg('文件上传中...', {time:3000000});
            },done: function(res, index, upload) {
                var obj = this.item;
                if (res.code == 0) {
                    layer.msg(res.msg);
                    return false;
                }
                layer.closeAll();
                var input = $(obj).parent().parent().find('.upload-input');
                if ($(obj).attr('lay-type') == 'image') {
                    input.siblings('img').attr('src', res.data.file).show();
                }
                input.val(ishttps+window.location.host+'/'+res.data.file);
            }
        });

  form.on('submit(systemsave)', function(data){
    console.log(JSON.stringify(data.field));
    data.field.lywq_pupop_status = data.field.lywq_pupop_status?data.field.lywq_pupop_status:'0';
    data.field.lywq_pupop_interval_type = data.field.lywq_pupop_interval_type?data.field.lywq_pupop_interval_type:'0';
    data.field.lywq_pupop_interval_number = data.field.lywq_pupop_interval_number?data.field.lywq_pupop_interval_number:'3';
    data.field.lywq_pupop_type = data.field.lywq_pupop_type?data.field.lywq_pupop_type:'1';
    
    data.field.lywq_Hpupop_type = data.field.lywq_Hpupop_type?data.field.lywq_Hpupop_type:'0';
    
    data.field.lywq_pupop_snow_status = data.field.lywq_pupop_snow_status?data.field.lywq_pupop_snow_status:'0';
    data.field.lywq_pupop_snow_type = data.field.lywq_pupop_snow_type?data.field.lywq_pupop_snow_type:'1';
    $.ajax({
        url: "save.php",
        data: data.field,
        type: "post", 
		dataType: 'json',
        success: function (data) {
			layer.msg(data.msg, {icon: data.icon});
            form.render();
            location.reload();
        },
        error: function () {
            layer.alert("保存配置执行异常!", {icon: 5});
        }
    });				  
    return false;	
  });
});

        $('.upload-img').hover(function (e){
            var e = window.event || e;
            var imgsrc = $(this).val();
            if(imgsrc.trim()==""){ return; }
            var left = e.clientX+document.body.scrollLeft+20;
            var top = e.clientY+document.body.scrollTop+20;
            $(".showpic").css({left:left,top:top,display:""});
            $(".showpic_img").attr("src", imgsrc);
        },function (e){
            $(".showpic").css("display","none");
        });
</script>
</body>
</html>